<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>sso登录</title>
</head>
<body>
    <h2>SSO登录</h2>
    <form action="doLogin" method="post">
        <p>用户名：<input name="username" ></p>
        <p>密码：<input name="password" ></p>
        <button type="submit">提交</button>
    </form>
</body>
</html>

<script type="text/javascript" >

    window.onload = function (){

        var returnUrl = getParam("returnUrl");
        if (returnUrl == undefined){
            return
        }

        var form = document.getElementsByTagName("form")[0];
        var inputElement = document.createElement("input");
        inputElement.setAttribute("hidden", "hidden")
        inputElement.setAttribute("name", "returnUrl")
        inputElement.setAttribute("value", returnUrl)
        // form.append('<input hidden="hidden" value="'+returnUrl+'" name="returnUrl" >')
        form.append(inputElement)

    }

    /**
     * 获取指定的URL参数值
     * URL:http://www.xxx.com/index?name=123
     * 参数：param URL参数
     * 调用方法:getParam("name")
     * 返回值:123
     * alert(getParam('date'));
     */
    function getParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        //search,查询？后面的参数，并匹配正则
        var r = location.search.substr(1).match(reg);
        if (r != null) return decodeURI(decodeURI(r[2]));
    }
</script>